from func_define import *
'''方案二：一次性分配最优函数'''
# 构建函数功能需求
# 输入：w ，表示养到w公斤就直接卖掉
# 输出：一共多少收益
# def way_2_count(w):
#     days = weight_day(w)                    # 到达 w kg时需要多少天
#     iters = int(365 * 3 // days)                 # 最高4次迭代
#     # day_put_get = days              # 每一批投放天数
#     weights = weight(q,days)         # 一条鱼第day_put_get天后的重量
#     weights = weights if weights<=2 else 2
#     nums_fish = 10000/weights              # 10000能容纳多少条鱼
#     cur_weight = nums_fish/500              # 多少重量
#     day = 1
#     cost_all_day = 0
#     while day < 1 + days:
#         '''假设每天喂完过后，就直接增长重量'''
#         # 当天的鱼的饲料的成本
#         cost_all_day += food_cost_day(cur_weight)   # 当天weight鱼的花费
#         # 第二天的重量更新，长大了
#         cur_weight = nums_fish * weight(q,day)             # 5000条鱼，每条鱼第day天的重量
#         # print(weights(q,day))
#         print(cur_weight)
#         day += 1
#     one_year_money = nums_fish * get_money(weights)
#     return iters*(one_year_money-cost_all_day)

def way_2_count_2(w):
    tep = 0.0
    days = int(360*math.log(500*w,1000))
    for d in range(1,days+1):
        tep+=0.00005*pow(1000,(d-1)/360)
    return (w*get_money(w)-tep)*int(1095.0/days)*int(10000/w)
# print(way_2_count(2.0))
# print(way_2_count(0.2))
# print(way_2_count(0.75))
# print(way_2_count(1.5))
'''
561326.0100756238
474780.92325323564
465487.7810343037
570445.6105180285
'''

print(way_2_count_2(2))

x = np.linspace(0.1,2,100)
y = []
max_index = 0
ans = 0
for i in range(len(x)):
    # print(i)
    temp = way_2_count_2(x[i])
    if temp>ans:
        ans = temp
        max_index = x[i]
    y.append(temp)

get_plot_show(x,y,xlabel=r'单条鱼的重量',ylabel=r'三年收益',label_name=None,title='三年收益随单条鱼重量设置变化图')
print(max_index,ans)
print(weight_day(max_index))